package com.bangdao.app.jetpacktest.jetpack.databinding.viewmodel;

import static android.content.ContentValues.TAG;

import android.util.Log;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;
import androidx.lifecycle.ViewModel;

import com.bangdao.app.jetpacktest.BR;
import com.bangdao.app.jetpacktest.jetpack.databinding.bean.LoginModel;
import com.bangdao.app.jetpacktest.jetpack.databinding.bean.LoginModel1;

/**
 * @ProjectName: JetpackTest
 * @ClassName: TwoWayBindingViewModel
 * @Description: java类作用描述
 * @Author: luhui
 * @Email: hui.lu@bangdao-tech.com
 * @CreateDate: 2022/6/4 23:05
 * @UpdateUser: luhui
 * @UpdateDate: 2022/6/4 23:05
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class TwoWayBindingViewModel1 extends BaseObservable {
    private LoginModel loginModel;

    public TwoWayBindingViewModel1() {
        loginModel = new LoginModel();
        loginModel.setUserName("Jack");
    }

    @Bindable
    public String getUserName() {
        return loginModel.getUserName();
    }

    public void setUserName(String userName) {
        loginModel.setUserName(userName);
        notifyPropertyChanged(BR.userName);
        //或者，直接刷新所有，getter方法上不需要加@Bindable，因为不需要生成BR资源
//        notifyChange();
    }
}
